<?php
namespace App\Services\Export;

use PhpOffice\PhpWord\TemplateProcessor;
use Illuminate\Support\Facades\Storage;

abstract class Wordabstract
{
	public $templateProcessor;



	public function __construct(TemplateProcessor $templateProcessor)
	{
		$this->templateProcessor = $templateProcessor;
	}

    abstract public function set();

    public function create($created,$docName) {
    	Storage::disk('public')->makeDirectory('word/'.$created);
    	$path = './storage/word/'.$created.'/'.$docName.'.docx';
        $this->templateProcessor->saveAs($path);
        // 同步保存pdf
		 // 生成pdf
        // $filepath=public_path().'/storage/word/'.$created.'/'.$docName.'.docx';
        // $outdir=public_path().'/storage/word/'.$created;
        // shell_exec('soffice --headless --invisible --convert-to pdf '.$filepath.' --outdir '.$outdir);

        return $path;
    }
}